Skip to content

refactor: map additional device export fields - #1233

Open
sinchubhat wants to merge 2 commits into
device-discovery-exportAPIfrom
issue1513-rpc-go
Open

refactor: map additional device export fields#1233
sinchubhat wants to merge 2 commits into
device-discovery-exportAPIfrom
issue1513-rpc-go

Conversation

@sinchubhat

@sinchubhat sinchubhat commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
  • persist ME and OS network details from rpc-go sync
  • map OS DNS suffix and platform adapters into export output
  • preserve fallback mapping for legacy flat IP fields
  • map the existing AMT BIOS state to the export MEBX field

Addresses device-management-toolkit/rpc-go#1513

Dependencies

Implementation Details:

Field Console export / mapping behavior
deviceInfo.dnsSuffixOS Stored on DeviceInfo and exported as deviceInfo.os.dnsSuffix.
deviceInfo.meNetwork.wired Exported as deviceInfo.me.network.wired when it contains at least one populated ME interface field.
deviceInfo.meNetwork.wireless Exported as deviceInfo.me.network.wireless when it contains at least one populated ME interface field.
deviceInfo.meNetwork.*.ipAddress Exported as deviceInfo.me.network.*.ipAddress.
deviceInfo.meNetwork.*.dhcpEnabled Exported as deviceInfo.me.network.*.dhcpEnabled.
deviceInfo.meNetwork.*.dhcpMode Exported as deviceInfo.me.network.*.dhcpMode.
deviceInfo.meNetwork.*.linkStatus Exported as deviceInfo.me.network.*.linkStatus.
deviceInfo.meNetwork.*.macAddress Exported as deviceInfo.me.network.*.macAddress.
Legacy deviceInfo.ipAddress / deviceInfo.dhcpEnabled Used as the ME wired-network fallback when nested meNetwork is absent or contains no usable interface data.
deviceInfo.osNetwork.wired[] Exported as deviceInfo.os.network.wired[]; empty wired interface objects are ignored.
deviceInfo.osNetwork.wireless Exported as deviceInfo.os.network.wireless when it contains at least one populated OS interface field.
deviceInfo.osNetwork.*.name Exported as deviceInfo.os.network.*.name.
deviceInfo.osNetwork.*.ipAddress Exported as deviceInfo.os.network.*.ipAddress.
deviceInfo.osNetwork.*.dhcpEnabled Exported as deviceInfo.os.network.*.dhcpEnabled; may be null when rpc-go cannot determine DHCP state.
deviceInfo.osNetwork.*.linkStatus Exported as deviceInfo.os.network.*.linkStatus.
deviceInfo.osNetwork.*.macAddress Exported as deviceInfo.os.network.*.macAddress.
Legacy deviceInfo.osIpAddress Used as the OS wired-network fallback when nested osNetwork is absent or contains no usable interface data.
deviceInfo.platformAdapters.wired[] Stored and exported as deviceInfo.platform.adapters.wired[], containing all detected wired adapter display names.
deviceInfo.platformAdapters.wireless[] Stored and exported as deviceInfo.platform.adapters.wireless[], containing all detected wireless adapter display names.
Legacy string platformAdapters.wired / platformAdapters.wireless Decoded as single-element arrays for compatibility with existing Console records.
deviceInfo.ethernetAdapterCount Exported as deviceInfo.platform.ethernetAdapterCount; it represents the total physical wired and wireless adapter count.
deviceInfo.amtEnabledInBIOS Exported as deviceInfo.me.mebxEnabledInBIOS; no duplicate stored mebxEnabledInBIOS field is introduced.
Empty meNetwork / osNetwork objects Suppressed so empty nested objects do not create misleading ME or OS subsystems.
Non-AMT / VM devices Can export OS/platform data while deviceInfo.me remains null.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.39%. Comparing base (a897fbf) to head (952a937).

Files with missing lines Patch % Lines
internal/entity/dto/v1/device.go 77.27% 5 Missing ⚠️
internal/usecase/devices/usecase.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           device-discovery-exportAPI    #1233      +/-   ##
==============================================================
+ Coverage                       58.20%   58.39%   +0.18%     
==============================================================
  Files                             150      150              
  Lines                           12329    12404      +75     
==============================================================
+ Hits                             7176     7243      +67     
- Misses                           5152     5160       +8     
  Partials                            1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The export shaping currently contains a non-compiling struct type conversion and a couple of export-presence/mapping edge cases that can drop or emit empty subsystems incorrectly.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Extends the /api/v1/devices/export shaping to include additional OS/ME/platform network-related fields being synced from rpc-go, while preserving legacy fallback behavior for flat IP fields.

Changes:

  • Adds nested DTO fields for OS DNS suffix, ME/OS network details, and platform adapter names on DeviceInfo.
  • Updates export shaping to emit ME/OS network structures (with legacy fallback to flat IP fields) and platform adapters.
  • Extends export endpoint test coverage to validate the newly-exported fields.
File summaries
File Description
internal/usecase/devices/usecase.go Adds merge/setter keys for new device-info fields so partial updates can persist them.
internal/entity/dto/v1/device.go Introduces new nested DeviceInfo DTO fields/types for OS DNS suffix, ME/OS network, and platform adapters.
internal/controller/httpapi/v1/export.go Maps the new nested fields into the export response while retaining legacy fallbacks.
internal/controller/httpapi/v1/export_test.go Adds assertions for DNS suffix, interface metadata, and platform adapters in export output.
Review details

Suppressed comments (1)

internal/controller/httpapi/v1/export.go:224

  • buildExportOS decides whether to emit the OS subsystem using hasOS, but it doesn't include the newly-added DNSSuffixOS or OSNetwork fields. If those are the only OS details present, the OS subsystem will incorrectly render as null even though data exists.
	hasOS := info.OSName != "" || info.OSVersion != "" || info.OSDistro != "" ||
		info.OSIPAddress != "" || info.LMSInstalled != nil || info.LMSVersion != "" ||
		info.MEInterfaceVersion != "" || info.MonitorConnected != nil || info.IEEE8021XEnabled != nil
	if !hasOS {
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/controller/httpapi/v1/export.go
Comment thread internal/controller/httpapi/v1/export.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The export mapping currently skips legacy IP fallbacks (and can suppress OS export entirely) when nested network/dns fields are present-but-empty or are the only OS data, which contradicts the intended backward-compatible behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

internal/controller/httpapi/v1/export.go:242

  • Same fallback issue as ME: if info.OSNetwork is non-nil but empty, buildExportOSNetwork returns nil and the legacy OSIPAddress fallback is skipped, resulting in a missing OS network in the export. Only prefer the nested mapping when it yields a non-nil export network.
	if info.OSNetwork != nil {
		osInfo.Network = buildExportOSNetwork(info.OSNetwork)
	} else if info.OSIPAddress != "" {
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread internal/controller/httpapi/v1/export.go Outdated
Comment thread internal/controller/httpapi/v1/export.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

buildExportOS currently treats an empty-but-non-nil osNetwork object as OS presence, which can cause an “empty” OS subsystem to be exported instead of null when no OS data was actually reported.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread internal/controller/httpapi/v1/export.go Outdated
@sinchubhat
sinchubhat force-pushed the issue1513-rpc-go branch 2 times, most recently from 0062372 to 837de43 Compare September 3, 2026 05:04
@sinchubhat
sinchubhat requested a lite review from Copilot September 3, 2026 05:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new 1:1 struct-literal mappings in export.go are likely to fail CI due to staticcheck S1016 and should be replaced with direct struct conversions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

internal/controller/httpapi/v1/export.go:298

  • This 1:1 field-copy struct literal is a candidate for staticcheck S1016. Since OSInterfaceInfo and ExportOSInterface have identical fields, prefer a direct conversion to avoid lint failures and reduce boilerplate.
	return &dto.ExportOSInterface{
		Name:        adapter.Name,
		IPAddress:   adapter.IPAddress,
		DHCPEnabled: adapter.DHCPEnabled,
		LinkStatus:  adapter.LinkStatus,
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread internal/controller/httpapi/v1/export.go Outdated
@sinchubhat
sinchubhat marked this pull request as ready for review September 3, 2026 05:42
@sinchubhat
sinchubhat requested a review from a team as a code owner September 3, 2026 05:42
@sinchubhat
sinchubhat force-pushed the issue1513-rpc-go branch 2 times, most recently from 120a2f4 to 87748a5 Compare September 8, 2026 02:49
* persist ME and OS network details from rpc-go sync
* map OS DNS suffix and platform adapters into export output
* preserve fallback mapping for legacy flat IP fields
* map the existing AMT BIOS state to the export MEBX field

Addresses device-management-toolkit/rpc-go#1513
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send missing OS/ME network adapter and DNS suffix fields required by Console export API

2 participants